<?php
class Period extends AppModel {

	var $name = 'Period';
	var $actsAs = array('Containable', 'Ownable');
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
		'User' => array(
			'className' => 'User',
			'foreignKey' => 'user_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Season' => array(
			'className' => 'Season',
			'foreignKey' => 'season_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
	
	function currentPeriods($user_id) {
		//$this->contain('Season');
		$params = array(
			'contain' => array('Season'=>'title'),
			'conditions' => array('Period.user_id' => $user_id),
			'recursive' => 0, //int
			'order' =>  array('Period.start_date' => 'asc'),
			'limit' => null
		);
		return $this->find('all', $params);
	}

}
?>